package com.simple.util.es;

import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

/**
 * @program: simple_tools
 * @description: 连接远程ES通道
 * @author: Mr.chen
 * @create: 2020-04-27 13:52
 **/
public class JschUtil {

    /**
     * 创建与远程跳板机的连接
     */
    private static void buildSession() {
        //bruce //rgj.nc8iei9J
        try {
            JSch jsch = new JSch();
            Session session = jsch.getSession("远程跳板机的用户名称", "远程跳板机地址", 56000);
            session.setPassword("远程跳板机的地址");
            session.setConfig("StrictHostKeyChecking", "no");
            session.connect();
            // 这里打印SSH服务器版本信息
            System.out.println(session.getServerVersion());
            // 端口映射 转发
            int assignedPort = session.setPortForwardingL("127.0.0.1", 9216, "192.168.40.8", 9216);
            System.out.println("localhost:" + assignedPort);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

